#!/bin/bash

PRJ_PATH='pwd'

DL_ADDR=http://master.iot-yun.club:2211/src/
function build_cjson()
{
    APP_SRC=cJSON-1.7.14
    if [ ! -f ${APP_SRC}.tar.gz ] ;then
        wget ${DL_ADDR}/${APP_SRC}.tar.gz
    fi

    if [ -f ${INST_PATH}/lib/libcjson.so ] ; then
        return ;
    fi

    if [ ! -d ${APP_SRC} ] ; then
        tar -xzf ${APP_SRC}.tar.gz
    fi

    cd ${APP_SRC}
    make && make install  PREFIX=${INST_PATH}
    cd -
}


#include<sqlite3.h>
function build_sqlite()
{
    APP_SRC=sqlite-autoconf-3350500
    if [ ! -f ${APP_SRC}.tar.gz ] ; then
        wget ${DL_ADDR}/${APP_SRC}.tar.gz

    fi

    if [ ! -d ${APP_SRC} ] ; then
        tar -xzf ${APP_SRC}.tar.gz
    fi

    cd ${APP_SRC}
    ./configure
    make && make install PREFIX=${INST_PATH}
    cd -
}

build_cjson
build_sqlite
